package com.admin.testproject

import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log

/**
 * author 吴昶
 * date 2019/6/4
 * 标注
 */

abstract class BaseActivity :AppCompatActivity(){

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestedOrientation = if(isIPad()){
            Log.e("***","isPad")
            ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
        }else{
            Log.e("***","isPhone")
            ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
        }
        setContentView(bindLayout())
        bindData()
        bindEvent()
    }

    abstract fun bindLayout():Int

    abstract fun bindData()

    abstract fun bindEvent()

    /**
     * 返回 平板 true
     * 手机 false
     */
    private fun isIPad():Boolean{
        return resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK >= Configuration.SCREENLAYOUT_SIZE_LARGE
    }
}